#ifndef MAPDRAW_H
#define MAPDRAW_H

#include <vector>
#include <SDL/SDL.h>

#include "backend/baseCTF.h"
#include "frontend-utils.h"



struct TilesetParams
{
	int gridtype;  // GRIDTYPE_ constants from baseCTF.h
	// should also contain whatever else is necessary--pixel size of each tile, etc.

	// convert a position on the tile grid into absolute pixel coordinates
	//  (i.e. one coordinate system for the entire map, which the UI window
	//  only shows a portion of)
	// ...this could return the center of the tile, or the UL corner of the bounding box,
	//  or whatever
	Point gridToPixel(const GridPos& pos);

	// given a pixel in absolute coords, find the map tile that it's a part of,
	//  or return an invalid GridPos if it's off the map
	GridPos pixelToGrid(const Point& pt);
};

struct HexTileset
{
	TilesetParams params;
	// should also contain a surface or bitmap or something with the tile images

	// load from file
	void init(const std::string& filename);
};


// fill in terrain with random values from the constants in baseCTF.h
void createRandomTerrain(const Size& size, std::vector<int>& terrain);


// draw a portion of the map onto surface: drect is the destination rectangle; tileset is the
//  set of tile images and also contains the parameters for converting between absolute pixel coords
//  and map tile coords; offset is the upper-left corner, in absolute pixel coords, of the viewed
//  portion of the map
void drawHexTerrain(SDL_Surface *surface, SDL_Rect drect, const HexTileset& tileset, const std::vector<int>& terrain, const Point& offset);



#endif // MAPDRAW_H